package com.java.tools.mouse.e1;

import java.awt.*;
import java.awt.event.InputEvent;
import java.util.Random;

/**
 * @author wangning
 * @create 2022-03-18 16:53
 */
public class OnmyojiTools {
	public static void main(String[] args) throws AWTException {
		Robot robot = new Robot();
		robot.delay(5000);
		int random = new Random().nextInt(5) * 1000;
		while (true) {
			extracted(robot);
			robot.delay(20000+random);
		}
	}

	/**
	 * 在指定位置执行一次鼠标单击
	 * @param robot 机器人对象
	 */
	private static void extracted(Robot robot) {
		int i = 10;
		int x = new Random().nextInt(20) - 10;
		int y = new Random().nextInt(20) - 10;
		while (i-- > 0) {
			robot.mouseMove(200 + x, 300 + y);
		}
		robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
		robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
	}
}
